package com.ruoyi.business.workshop.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.ruoyi.business.communication.domain.SlotTiming;

/**
 * 槽位时间设置响应DTO
 * 
 * @author ruoyi
 */
public class SlotTimingResponseDTO implements Serializable {

    private static final long serialVersionUID = 1L;

    /** 业务槽号 */
    private Integer businessSlotNo;

    /** 点位数（4或6） */
    private Integer pointsPerSlot;

    /** 点位时间设置列表 */
    private List<PositionTiming> positionTimings;

    public SlotTimingResponseDTO() {
        this.positionTimings = new ArrayList<>();
    }

    /**
     * 从SlotTiming对象构造DTO
     */
    public SlotTimingResponseDTO(SlotTiming slotTiming) {
        this();
        if (slotTiming == null) {
            return;
        }
        
        this.businessSlotNo = slotTiming.getBusinessSlotNo();
        this.pointsPerSlot = slotTiming.getPositionCountPerSlot() == 
            com.ruoyi.business.communication.domain.PositionCountPerSlot.SIX ? 6 : 4;
        
        // 遍历所有点位，提取时间信息
        for (int i = 1; i <= this.pointsPerSlot; i++) {
            PositionTiming pt = new PositionTiming();
            pt.setPositionNumber(i);
            
            // 打壳时间（转换为秒）
            Double strikeTime = slotTiming.getStrikeTimeSeconds(i);
            pt.setStrikeTimeSeconds(strikeTime);
            
            // 阶段1时间（分钟）
            pt.setStage1Minutes(slotTiming.getStage1Minutes(i));
            
            // 阶段2时间（分钟）
            pt.setStage2Minutes(slotTiming.getStage2Minutes(i));
            
            this.positionTimings.add(pt);
        }
    }

    public Integer getBusinessSlotNo() {
        return businessSlotNo;
    }

    public void setBusinessSlotNo(Integer businessSlotNo) {
        this.businessSlotNo = businessSlotNo;
    }

    public Integer getPointsPerSlot() {
        return pointsPerSlot;
    }

    public void setPointsPerSlot(Integer pointsPerSlot) {
        this.pointsPerSlot = pointsPerSlot;
    }

    public List<PositionTiming> getPositionTimings() {
        return positionTimings;
    }

    public void setPositionTimings(List<PositionTiming> positionTimings) {
        this.positionTimings = positionTimings;
    }

    /**
     * 点位时间设置
     */
    public static class PositionTiming implements Serializable {
        private static final long serialVersionUID = 1L;

        /** 点位编号（1-6） */
        private Integer positionNumber;

        /** 打壳时间（秒） */
        private Double strikeTimeSeconds;

        /** 换极阶段1时间（分钟） */
        private Integer stage1Minutes;

        /** 换极阶段2时间（分钟） */
        private Integer stage2Minutes;

        public Integer getPositionNumber() {
            return positionNumber;
        }

        public void setPositionNumber(Integer positionNumber) {
            this.positionNumber = positionNumber;
        }

        public Double getStrikeTimeSeconds() {
            return strikeTimeSeconds;
        }

        public void setStrikeTimeSeconds(Double strikeTimeSeconds) {
            this.strikeTimeSeconds = strikeTimeSeconds;
        }

        public Integer getStage1Minutes() {
            return stage1Minutes;
        }

        public void setStage1Minutes(Integer stage1Minutes) {
            this.stage1Minutes = stage1Minutes;
        }

        public Integer getStage2Minutes() {
            return stage2Minutes;
        }

        public void setStage2Minutes(Integer stage2Minutes) {
            this.stage2Minutes = stage2Minutes;
        }
    }
}

